'''
class Solution:
    def minNumberdisappered(self, arr):
        # write code here
        for i in range(len(arr)):
            if arr[i]>0:
                break
        # 保存数组的话空间复杂度不为O(1)
        arr = arr[i:]
        # print(arr,i)
        for j in range(len(arr)-i):
            if arr[j] != j+1:
                return j+1
        return j+2

arr = [-2,-1,2,3,4,5]
so = Solution()
res=so.minNumberdisappered(arr)
print(res)'''
# 直接操作索引
class Solution:
    def minNumberdisappered(self , arr ):
        # write code here
        for i in range(len(arr)):
            if arr[i]>0:
                break
        for j in range(len(arr)-i):
            if arr[j+i] != j+1:
                return j+1
        return j+2
arr = [1,2,3,5]
so = Solution()
res=so.minNumberdisappered(arr)
print(res)